//
//  CommonViewController.m
//  edu
//
//  Created by baobaodp on 13-8-12.
//  Copyright (c) 2013年 baobaodp. All rights reserved.
//

#import "CommonViewController.h"
#import "CommonNavbar.h"
#import "EduViewController.h"

#import <QuartzCore/QuartzCore.h>

@interface CommonViewController ()

@end

@implementation CommonViewController

@synthesize currentView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    //float initialRed = 0;
    //float initialGreen = 126;
    //float initialBlue = 129;
    //self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:initialRed/255.0f green:initialGreen/255.0f blue:initialBlue/255.0f alpha:1.0f];
    
    //now, set the initial adjustment factor of the tint by casting the navigation controllers navigationBar to our class, and setting the property. I'll set it to 1.2 for now to make it slightly lighter.
    //((CommonNavbar *)self.navigationController.navigationBar).colourAdjustFactor = 1.2;

    //设置导航bar的字体颜色为白色
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
    if(IOS7_OR_LATER){
        [[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"backicon.png"]];
        [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"backicon.png"]];
    }
    //修改返回按钮的图片
    
}

- (void)switchViews:(UIView *)targetView transition:(int) direct
{

    
    currentView = targetView;
    

    CATransition *animation = [CATransition animation];
    animation.delegate = self;
    animation.duration = 0.3f;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    //animation.type = kCATransitionMoveIn;
    animation.type = kCATransitionPush;
    if(direct == 0){
        //animation.subtype = kCATransitionFromTop;
        animation.subtype = kCATransitionFade;
    }else if(direct == 3){
        animation.subtype = kCATransitionFade;
    }else if(direct == 4){
        animation.subtype = kCATransitionFade;
        animation.duration = 0.0f;
    }else{
        //animation.subtype = kCATransitionFromBottom;
        animation.subtype = kCATransitionFade;
    }
    [self.view.layer addAnimation:animation forKey:@"animation"];
    
    [self.view bringSubviewToFront:targetView];
    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 *导航栏的风格修改为亮色
 *
 */
-(UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

@end
